<template>
  <div class="tableListSocial">
    <!--头部-->
    <el-row class="top">
      <el-col :span="4">用户id</el-col>
      <el-col :span="6">发送时间</el-col>
      <el-col :span="6">评论时间</el-col>
      <el-col :span="8">
        <el-select placeholder="请选择平台账号" multiple style="width: 90%"
                   collapse-tags  v-model="currentAccount" size="mini" @change="changeAccount">
          <el-option value="" label="全部" ></el-option>
          <el-option v-for="item in account" :key="item.id" :label="item.accountEmail"
                     :value="item.id">
          </el-option>
        </el-select>
      </el-col>
    </el-row>
    <el-row v-for="item,index in tableData" :key="index">
      <el-col :span="4" class="more">{{filterStr(item.commentName)}}</el-col>
      <el-col :span="6">{{filterStr(item.feedCreateTime)}}</el-col>
      <el-col :span="6">{{filterStr(item.commentCreateTime)}}</el-col>
      <el-col :span="8">{{filterStr(item.accountEmail)}}</el-col>
    </el-row>
    <div class="empty" v-show="total==0">
      <img src="../../../../public/img/empty.png" alt="">
    </div>
    <el-pagination align="right" style="margin-top: 15px" v-show="total>0"
                   @size-change="handleSizeChange"
                   @current-change="handleCurrentChange"
                   :current-page.sync="nowPage"
                   :page-sizes="[10, 20, 30, 50]"
                   :page-size="nowSize"
                   layout="prev, pager, next, sizes"
                   :total="total">
    </el-pagination>
  </div>
</template>

<script>
    import {getSocialComment} from '@/api/marketStatic/social'
    export default {
        name: "TableListSocial",
        props:['id','account'],
        data() {
            return {
                tableData:[],
                nowPage: 1,
                nowSize: 10,
                total: 0,
                currentAccount:[]
            };
        },
        mounted(){
            this.getComment();//获取点赞数
        },
        methods: {
            getComment(){
                const params={
                    ruleId:this.id,
                    pageSize:this.nowSize,
                    pageNo:this.nowPage,
                    accounts: this.currentAccount.length>0?this.currentAccount.join(','):''
                }
                getSocialComment(params).then(res => {
                    if (res.data.success) {
                        this.tableData=res.data.data.records;
                        this.total = res.data.data.total;
                        this.$emit('getcommentCount',this.total)
                    }
                })
            },
            changeAccount(){
                this.nowPage=1;
                this.getComment();
            },
            handleSizeChange(size) { //  条数发生改变
                this.nowSize = size
                this.getComment()
            },
            handleCurrentChange(page) { //页数发生变化
                this.nowPage = page
                this.getComment()
            },
            filterStr(str) {
                if (str) return str;
                return '-'
            }
        }
    }
</script>

<style scoped>

</style>
